<?php
/*
Plugin Name: Que hay al toque Widget
Plugin URI: http://rosarioaltoque.org.ar
Description: Un widget para mostrar que hay al toque
Author: Pampacom CDT
Author URI: http://pampacomcdt.com.ar
Version: 0.4
*/
add_action("widgets_init", array('Widget_Que_hay_al_toque', 'register'));
class Widget_Que_hay_al_toque extends WP_Widget {
	function Widget_Que_hay_al_toque() {
		$widget_ops = array( 'classname' => 'Widget_Que_hay_al_toque');
		$control_ops = array( 'width' => 850, 'height' => 350, 'id_base' => 'que-hay-al-toque-widget' );
		$this->WP_Widget( 'que-hay-al-toque-widget', __('Widget Que_hay_al_toque', 'a'), $widget_ops, $control_ops );
	}
	function control(){
    	echo 'I am a control panel';
	}
	function widget($args){
		extract( $args );
		$title = "Al toque";
		
    	echo $args['before_widget'];
	    echo $args['before_title'] . $title . $args['after_title'];
		wp_enqueue_script('OpenLayers');

echo					'<style>
					.smallmap {width: 256px;height: 128px;border: 1px solid #ccc;}
					</style>
					<!--script src="http://maps.google.com/maps/api/js?sensor=false"></script-->
					<!--script src="/wp-content/themes/rcd/js/OpenLayers.js"></script-->
					<div id="mapw" class="smallmap"></div>
					<script>
						var map = new OpenLayers.Map("mapw");
						
						var wms_rosario = new OpenLayers.Layer.WMS(
							"WMS-Rosario",
							"http://www.rosario.gov.ar/wms/planobase",
							{layers: "WMS-Rosario"}
						);
						map.addLayer(wms_rosario);
						var wms_rosario = new OpenLayers.Layer.WMS(
							"FotosAreas2005",
							"http://www.rosario.gov.ar/wms/planobase",
							{layers: "FotosAreas2005"}
						);
/*						var osm = new OpenLayers.Layer.OSM();
						var gmap = new OpenLayers.Layer.Google("Google Streets", {visibility: false});
						map.addLayers([osm, gmap]);*/
						
						map.addLayer(wms_rosario);
						var wms_rosario_no_base = new OpenLayers.Layer.WMS(
							"Manzanas",
							"http://www.rosario.gov.ar/wms/planobase",
							{layers: "manzanas,sentidos_de_calle", transparent: "TRUE"},
							{isBaseLayer: false, visibility: false}
						);
						map.addLayer(wms_rosario_no_base);

						var yelp = new OpenLayers.Icon("/wp-content/themes/rcd/images/cortes-y-desvios.png", new OpenLayers.Size(49,44));
						var newl = new OpenLayers.Layer.GeoRSS( "GeoRSS", "/feed/", {"icon":yelp});
						map.addLayer(newl);
						
						map.setCenter(new OpenLayers.LonLat(-60.665817, -32.949911), 14);
						map.addControl(new OpenLayers.Control.LayerSwitcher());
//						map.zoomToMaxExtent();
					</script>
					<script src="/wp-content/themes/rcd/js/geolocation.js"></script>';

	    
	    echo $args['after_widget'];
	}
	function register(){
		register_sidebar_widget('Que_hay_al_toque', array('Widget_Que_hay_al_toque', 'widget'));
		register_widget_control('Que_hay_al_toque', array('Widget_Que_hay_al_toque', 'control'));
	}
}

?>
